#if CSVFMTS_ENABLED
/*****************************************************************************/
/* dec_to_intdeg() - convert decimal degrees to integer degreees */
-/* usage: i = dec_to_intdeg(31.1234, 1); */
-/* i = dec_to_intdeg(91.1234, 0); */
+/* usage: i = dec_to_intdeg(31.1234); */
/*****************************************************************************/
static int
-dec_to_intdeg(const double d, const int islat)
+dec_to_intdeg(const double d)
{
int ideg = 0;
- if (islat) {
+ if (d >= 0) {
ideg = (2147483647) - (d * 8388608);
} else {
ideg = (2147483647) - (fabs(d) * 8388608) + 1;
/*****************************************************************************/
/* intdeg_to_dec() - convert integer degrees to decimal degreees */
-/* usage: lat = dec_to_intdeg(ilat, 1); */
-/* lon = dec_to_intdeg(ilon, 0); */
+/* usage: lat = dec_to_intdeg(ilat); */
/*****************************************************************************/
static double
-intdeg_to_dec(const int ideg, const int islat)
+intdeg_to_dec(const int ideg)
{
double d;
- if (islat) {
+ if (ideg >= 0) {
d = ((2147483647) - ideg) / (double)8388608;
} else {
d = ((-2147483647-1) + ideg) / (double)8388608;
} else
if (strcmp(fmp->key, "LAT_INT32DEG") == 0) {
/* latitude as a 32 bit integer offset */
- wpt->latitude = intdeg_to_dec((int) atof(s), 1);
+ wpt->latitude = intdeg_to_dec((int) atof(s));
} else
if ( strcmp(fmp->key, "LAT_HUMAN_READABLE") == 0) {
human_to_dec( s, &wpt->latitude, &wpt->longitude, 1 );
} else
if (strcmp(fmp->key, "LON_INT32DEG") == 0) {
/* longitude as a 32 bit integer offset */
- wpt->longitude = intdeg_to_dec((int) atof(s), 0);
+ wpt->longitude = intdeg_to_dec((int) atof(s));
} else
if ( strcmp(fmp->key, "LON_HUMAN_READABLE") == 0) {
human_to_dec( s, &wpt->latitude, &wpt->longitude, 2 );
if (strcmp(fmp->key, "LAT_INT32DEG") == 0) {
/* latitude as an integer offset from 0 degrees */
writebuff(buff, fmp->printfc,
- dec_to_intdeg(lat, 1));
+ dec_to_intdeg(lat));
} else
if (strcmp(fmp->key, "LAT_HUMAN_READABLE") == 0) {
dec_to_human( buff, fmp->printfc, "SN", lat );
if (strcmp(fmp->key, "LON_INT32DEG") == 0) {
/* longitudee as an integer offset from 0 degrees */
writebuff(buff, fmp->printfc,
- dec_to_intdeg(lon, 0));
+ dec_to_intdeg(lon));
} else
if (strcmp(fmp->key, "LON_HUMAN_READABLE") == 0) {
dec_to_human( buff, fmp->printfc, "WE", lon );